package rozetka.pageObjects;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class RegisterDataInputForm {
	WebDriver driver;
	private static final By userNameInput = By.xpath("/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/form/div[1]/input");
	private static final By emailInput = By.xpath("/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/form/div[2]/input");
	private static final By passInput = By.xpath("/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/form/div[3]/input");
	private static final By buttonForRegistration = By.xpath("/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/form/div[6]/button");
	                                                          
	public RegisterDataInputForm(WebDriver webDrivder) {
		driver = webDrivder;
	}

	public void fillUserName(String userName) {
		driver.findElement(userNameInput).sendKeys(userName);
      
	}
	
	public void fillEmailInput (String email) {
		driver.findElement(emailInput).sendKeys(email);
      
	}
	
    public void fillPassword(String passw) {
        driver.findElement(passInput).sendKeys(passw);
     
	}
    
    public MyCabinet succesfullRegistration() {
        driver.findElement(buttonForRegistration).submit();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        return new MyCabinet(driver);
    }
    
    public String getUrl() {
    	return driver.getCurrentUrl();
    }
    
    public WebElement getRegisterButton() {
    	return driver.findElement(buttonForRegistration);
    }
    
    public void failRegistration() {
       driver.findElement(buttonForRegistration).submit();
       
    }

}
